﻿<%@ Page Title="Proyectos" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
	CodeBehind="Default.aspx.cs" Inherits="TraceThisItem.WebUI.Projects._Default" %>

<asp:Content ID="Head" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Body" ContentPlaceHolderID="MainContent" runat="server">
	<asp:ScriptManager ID="ScriptManager1" runat="server">
	</asp:ScriptManager>
	<h2>
		Proyectos
	</h2>
	<p>
		<asp:HyperLink NavigateUrl="~/Projects/Create.aspx" runat="server" Text="Crear proyecto" /></p>
	<asp:UpdatePanel ID="UpdatePanel1" runat="server">
		<ContentTemplate>
			<asp:GridView ID="ProjectGridView" runat="server" AutoGenerateColumns="False" DataSourceID="ProjectDataSource"
				Width="100%" DataKeyNames="Id,CreatedOn" EmptyDataText="No hay proyectos" 
				onrowcommand="ProjectGridView_RowCommand">
				<Columns>
					<asp:BoundField DataField="Name" HeaderText="Nombre" SortExpression="Name">
					</asp:BoundField>
					<asp:TemplateField HeaderText="Propietario" SortExpression="Owner">
						<EditItemTemplate>
							<asp:DropDownList ID="UserDropDownList" runat="server" DataSourceID="UserDataSource"
								DataTextField="FullName" DataValueField="UserName" SelectedValue='<%# Bind("OwnerUserName") %>'
								AppendDataBoundItems="true">
								<asp:ListItem Text="(Ninguno)" Value=""></asp:ListItem>
							</asp:DropDownList>
						</EditItemTemplate>
						<ItemTemplate>
							<asp:Literal ID="OwnerLiteral" runat="server" Text='<%# Eval("Owner") ?? "(Ninguno)" %>'></asp:Literal>
						</ItemTemplate>
						<HeaderStyle Width="20%" />
					</asp:TemplateField>
					<asp:BoundField DataField="CreatedOn" HeaderText="Fecha de creación" SortExpression="CreatedOn"
						DataFormatString="{0:d}" ReadOnly="true" HtmlEncode="False" HtmlEncodeFormatString="False"
						HeaderStyle-Width="30%">
						<HeaderStyle Width="20%" />
					</asp:BoundField>
					<asp:TemplateField ShowHeader="False">
						<EditItemTemplate>
							<asp:ImageButton ID="UpdateImageButton" runat="server" CausesValidation="True" CommandName="Update"
								ImageUrl="~/Styles/Images/saveHS.png" Text="Actualizar" />
							&nbsp;<asp:ImageButton ID="CancelImageButton" runat="server" CausesValidation="False"
								CommandName="Cancel" ImageUrl="~/Styles/Images/Edit_UndoHS.png" Text="Cancelar" />
						</EditItemTemplate>
						<ItemTemplate>
							<asp:ImageButton ID="EditImageButton" runat="server" CausesValidation="False" CommandName="Edit"
								ImageUrl="~/Styles/Images/EditInformationHS.png" Text="Editar" />
							&nbsp;<asp:ImageButton ID="DeleteImageButton" runat="server" CausesValidation="False"
								CommandName="Delete" ImageUrl="~/Styles/Images/DeleteHS.png" Text="Eliminar"
								OnClientClick="return confirm('¿Está seguro que desea eliminar este proyecto?')" />
								&nbsp;<asp:ImageButton ID="ViewItemTypesImageButton" runat="server" CausesValidation="False"
								ImageUrl="~/Styles/Images/NewDocumentHS.png" Text="Ver tipos de item" CommandName="ViewItemTypes" 
								CommandArgument='<%# Eval("Id") %>'/>
						</ItemTemplate>
						<HeaderStyle Width="7%" />
					</asp:TemplateField>
				</Columns>
			</asp:GridView>
			<asp:ObjectDataSource ID="ProjectDataSource" runat="server" DataObjectTypeName="TraceThisItem.Domain.Project"
				DeleteMethod="RemoveProject" SelectMethod="GetProjects" TypeName="TraceThisItem.Domain.Facade"
				OnObjectCreating="ProjectDataSource_ObjectCreating" OldValuesParameterFormatString="{0}"
				UpdateMethod="UpdateProject"></asp:ObjectDataSource>
			<asp:ObjectDataSource ID="UserDataSource" runat="server" DataObjectTypeName="TraceThisItem.Domain.User"
				SelectMethod="GetUsers" TypeName="TraceThisItem.Domain.Facade" OnObjectCreating="UserDataSource_ObjectCreating">
			</asp:ObjectDataSource>
		</ContentTemplate>
	</asp:UpdatePanel>
</asp:Content>
